<template>
  <aside class="detail-guide" :class="{'isTop': top === 0}" :style="{'top': top + 'px'}">
    <div class="detail-header-title">
      <i class="iconfont icon-arrow_1_1" @click="$router.back()"></i>
      <h3>{{data.title}}</h3>
      <i class="iconfont icon-Share" @click="$emit('onShare')"></i>
    </div>
    <div class="detail-header-right" ref="scroll">
      <ul class="detail-header-ul clearfix">
        <li :class="{'active': index === 0}" @click="clickGuideMenu(0)">Overview</li>
        <li :class="{'active': index === 1}" @click="clickGuideMenu(1)">Specifications</li>
        <!-- <li :class="{'active': index === 2}" @click="clickGuideMenu(2)">Service support</li> -->
        <!-- <li :class="{'active': index === 3}" class="disable" @click="clickGuideMenu(3)">{{$t('DEFAULT.REVIEWS')}}</li> -->
        <!-- <li :class="{'active': index === 4}" @click="clickGuideMenu(4)">Recommendation</li> -->
      </ul>
      <button class="detail-header-buy" :class="{'disable': !data.amazon_buy_link}" @click="openLink(data.amazon_buy_link)">{{data.amazon_buy_link ? $t('DEFAULT.BUYONAMAZON') : 'Unavallable for your area'}}</button>
    </div>
  </aside>
</template>

<script>
import { productAmazonButtonClickFunc } from '@/utils/kanban.js'
export default {
  props: {
    top: {
      type: [Number, String],
      default() {
        return 65
      }
    },
    title: String,
    data: {
      type: Object,
      default() {
        return {}
      }
    },
    index: {
      type: [Number, String],
      default() {
        return 0
      }
    }
  },
  methods: {
    clickGuideMenu(i) {
      this.$emit('change', i)
    },
    openLink (link) {
      let url = link
      if (url.indexOf('http')  == -1){
        url = 'http://' +link
      }
      productAmazonButtonClickFunc(this.data.product_name)
      window.open(url, '_blank')
    },
  }
}
</script>

<style lang="scss">
  .clearfix:after{
    content:"";
    display:block;
    height:0;
    clear:both;
    visibility:hidden;
  }
  .clearfix{zoom:1}
  .detail-guide {
    position: fixed;
    left: 0;
    right: 0;
    width: 100vw;
    min-width: 1200px;
    height: 72px;
    transition: none;
    background: white;
    display: flex;
    padding: 0 7.5%;
    border-bottom: 1px solid #EAEAEA;
    justify-content: space-between;
    align-items: center;
    z-index: 9;
    overflow: hidden;
  }
  .detail-guide.isTop {
    transition: top .6s;
  }
  .detail-header-title {
    font-size: 18px;
    color: #191919;
    max-width: 45%;

    i {
      display: none;
    }

    h3 {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
  .detail-header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }
  .detail-header-ul {
    list-style: none;

    .disable {
      color: #DEE0DB;
      cursor: not-allowed;
      pointer-events: none;
    }
  }
  .detail-header-ul li {
    position: relative;
    height: 71px;
    line-height: 72px;
    cursor: pointer;
    font-size: 16px;
    color: #191919;
    float: left;
    margin-left: 32px;

    &::after {
      content: "";
      position: absolute;
      height: 2px;
      width: 100%;
      background: #A5AF99;
      bottom: 0;
      left: 0;
      z-index: 10;
      transform: scaleX(0);
      transition: .3s ease-out;
    }

    &:hover {
      color: #6c7e59;

      // &::after {
      //   transform: scaleX(1);
      // }
    }
  }
  .detail-header-ul li.active {
    color: #6C7E59;
    font-weight: bold;
    
    &::after {
      background: #6C7E59;
      transform: scaleX(1);
    }
  }
  .detail-header-buy {
    cursor: pointer;
    margin-left: 32px;
    // width: 160px;
    padding: 0 24px;
    height: 48px;
    font-size: 14px;
    color: white;
    border-radius: 4px;
    background: #6C7E59;
    border: 0;

    &:hover {
      background: #A5AF99;
    }
  }
  .detail-header-buy.disable {
    background: #DEE0DB;
    cursor: not-allowed;
  }
  @media screen and (max-width: 1880px) {
    .detail-header-title {
      width: 40%;
    }
  }
  @media screen and (max-width: 1726px) {
    .detail-header-title {
      width: 35%;
    }
  }
  @media screen and (max-width: 1590px) {
    .detail-header-title {
      width: 30%;
    }
  }
  @media screen and (max-width: 1475px) {
    .detail-header-title {
      width: 20%;
    }
  }
  @media screen and (max-width: 768px) {
    .detail-guide {
      padding: 0 20px;
      height: 80px;
      display: block;
      overflow: hidden;
      min-width: 100%;
    }
    .detail-header-title {
      display: flex;
      align-items: center;
      height: 40px;
      font-size: 14px;
      padding: 0;
      max-width: 100%;
      width: 100%;

      i {
        display: block;
        font-size: 18px;
      }
      
      h3 {
        padding: 0 12px;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: center;
      }
    }
    .detail-header-right {
      height: 40px;
      overflow-x: auto;
      ::-webkit-scrollbar {
        display: none;
      }
    }
    .detail-header-ul {
      display: flex;
      flex-wrap: nowrap;
    }
    .detail-header-ul li {
      flex-shrink: 0;
      color: #6D6D6D;
      font-size: 14px;
      height: 38px;
      line-height: 40px;
      margin: 0 8px;
    }
    .detail-header-ul li.active {
      font-weight: normal;
    }
    .detail-header-buy {
      display: none;
    }
  }
</style>